Imports System.Data.OracleClient


Public Class clsScls

  Public mCmdSubClass As OracleCommand
  Public mDrSubClass As OracleDataReader

  Public mIntSubClassId As Integer
  Public mStrSubClassName As String
  Public mStrSubClassScope As String
  Public mIntSubClassPack As Integer
  Public mIntSubClassMclsId As Integer





  Public Function fnSelectScls() As Boolean

    Dim lStrQuery As String = ""

    If mIntSubClassId <> 0 Then
      lStrQuery = "select SCLS_CLAS_IDXX,SCLS_CLAS_NAME,SCLS_MAIN_CLAS_IDXX,SCLS_SCOP,SCLS_PACK from "
      lStrQuery = lStrQuery & "TRDX_SUB_CLASS where SCLS_CLAS_IDXX = " & mIntSubClassId
      lStrQuery = lStrQuery & " AND SCLS_MAIN_CLAS_IDXX = " & mIntSubClassMclsId


      mCmdSubClass = New OracleCommand(lStrQuery, con)
      mDrSubClass = mCmdSubClass.ExecuteReader

      fnSelectScls = True
    Else
      MessageBox.Show("Invalid Values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      fnSelectScls = False
    End If

  End Function




  Public Function fnInsertScls() As Integer

    Dim lIntSeqNum As Integer
    Dim lStrQuery As String


    mCmdSubClass = New OracleCommand("select count(*) as CNT from TRDX_SUB_CLASS", con)
    Dim nCount As Integer = mCmdSubClass.ExecuteScalar()

    If nCount = 0 Then
      lIntSeqNum = 0
    Else
      mCmdSubClass = New OracleCommand("select max(SCLS_CLAS_IDXX) as CNT from TRDX_SUB_CLASS", con)
      lIntSeqNum = mCmdSubClass.ExecuteScalar
    End If

    lStrQuery = "insert into TRDX_SUB_CLASS values(" & (lIntSeqNum + 1) & ",'" & mStrSubClassName & "',"
    lStrQuery = lStrQuery & mIntSubClassId & ",'" & mStrSubClassScope & "'," & mIntSubClassPack & ")"

    mCmdSubClass = New OracleCommand(lStrQuery, con)
    mCmdSubClass.ExecuteNonQuery()
    fnInsertScls = lIntSeqNum + 1

  End Function




  Public Function fnUpdateScls() As Boolean

    Dim lstrQuery As String = ""


    mCmdSubClass = New OracleCommand("select count(*) as CNT from TRDX_SUB_CLASS where SCLS_CLAS_IDXX = " _
                                    & mIntSubClassId, con)
    Dim ncount As Integer = mCmdSubClass.ExecuteScalar

    If ncount <> 0 Then
      lstrQuery = "update TRDX_SUB_CLASS set SCLS_CLAS_NAME = '" & mStrSubClassName & "',"
      lstrQuery = lstrQuery & "SCLS_SCOP = '" & mStrSubClassScope & "',"
      lstrQuery = lstrQuery & "SCLS_MAIN_CLAS_IDXX = " & mIntSubClassMclsId & ","
      lstrQuery = lstrQuery & "SCLS_PACK = " & mIntSubClassPack
      lstrQuery = lstrQuery & " where SCLS_CLAS_IDXX = " & mIntSubClassId
      mCmdSubClass = New OracleCommand(lstrQuery, con)
      mCmdSubClass.ExecuteNonQuery()
      fnUpdateScls = True
    Else
      MessageBox.Show("Invalid values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      fnUpdateScls = False
    End If

  End Function




  Public Function fnSelectAllScls() As Boolean

    Dim lStrQuery As String = ""


    lStrQuery = "select SCLS_CLAS_IDXX,SCLS_CLAS_NAME,SCLS_MAIN_CLAS_IDXX,SCLS_SCOP,SCLS_PACK from TRDX_SUB_CLASS"

    mCmdSubClass = New OracleCommand(lStrQuery, con)
    mDrSubClass = mCmdSubClass.ExecuteReader

    fnSelectAllScls = True

  End Function

  Public Function fnSelectSclsBasdMcls() As Boolean

    Dim lStrQuery As String

    If mIntSubClassMclsId <> 0 Then
      lStrQuery = "select SCLS_CLAS_IDXX,SCLS_CLAS_NAME,SCLS_MAIN_CLAS_IDXX,SCLS_SCOP,SCLS_PACK"
      lStrQuery = lStrQuery & " from TRDX_SUB_CLASS where  SCLS_MAIN_CLAS_IDXX = " & mIntSubClassMclsId.ToString
      lStrQuery = lStrQuery & " order by  SCLS_CLAS_IDXX"


      mCmdSubClass = New OracleCommand(lStrQuery, con)
      mDrSubClass = mCmdSubClass.ExecuteReader

      fnSelectSclsBasdMcls = True
    Else
      MessageBox.Show("Invalid Values", gCONST_MSG_HEADER, MessageBoxButtons.OK)
      fnSelectSclsBasdMcls = False
    End If

  End Function

End Class
